package com.gameShare.controller.misc

import com.gameShare.constances.FilePaths
import com.gameShare.controller.base.LoginVerifyController
import com.gameShare.enums.misc.HttpContentTypeEnum
import com.gameShare.service.misc.FileService
import jakarta.servlet.http.HttpServletResponse
import jakarta.validation.constraints.NotEmpty
import org.springframework.validation.annotation.Validated
import org.springframework.web.bind.annotation.RequestMapping
import org.springframework.web.bind.annotation.RestController


@RestController
@RequestMapping("/file")
@Validated
open class FileController(
    private val filePaths: FilePaths,
    private val fileService : FileService
) : LoginVerifyController(){


    /**
     * 获取服务端的image
     *
     * @param httpServletResponse 返回的图片放请求体中
     * @param path 图片路径
     */
    //TODO 要检查path路径防止攻击
    @RequestMapping("/getImage")
    open fun getImage(httpServletResponse: HttpServletResponse, @NotEmpty path : String){

        fileService.readImages(
            httpServletResponse,
            path,
            HttpContentTypeEnum.IMAGE,
            200)
    }

    // TODO 权限管理注解 用户专属方法
    @RequestMapping("/uploadImage")
    open fun uploadImage(){

    }
}